package kusterordonio.interfaz;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.util.*;
import java.text.*;

import kusterordonio.dominio.*;

public class VentanaEmbarazo extends javax.swing.JFrame {

    private SistemaCarne modelo;
    private Ninio niño;
    private boolean caso;
    
    /** Creates new form VentanaEmbarazo */
    public VentanaEmbarazo() {
        initComponents();
    }
    
    public VentanaEmbarazo(SistemaCarne unSistema, Ninio unNiño, boolean unCaso) {
        modelo = unSistema;
        niño = unNiño;
        caso = unCaso;
        initComponents();
        controlGenero();
        deshabilitarCampos();
        controlCaso();
        cargarDatos();
        habilitarCampos();
        ocultarCampos();
        jLabelCambio.setVisible(false);
        jLabelErrores.setVisible(false);
        jBtnSalir.setMnemonic(KeyEvent.VK_S);
        jBtnConfirmar.setMnemonic(KeyEvent.VK_C);
    }
    
    //setea los elementos de la ventana según el rol del actor
    public void controlCaso(){
        jTxtCualEmbarazo.setEditable(caso);
        jTxtCualParto.setEditable(caso);
        jTxtCualPuerperio.setEditable(caso);
        jTxtTratamiento.setEditable(caso);
        jTxtNumEmbarazo.setEditable(caso);
        jTxtNumControles.setEditable(caso);
        jRadioEmbUnico.setEnabled(caso);
        jBtnConfirmar.setVisible(caso);
        jRadioEmbUnico.setEnabled(caso);
        jRadioEmbUnico.setEnabled(caso);
        jRadioVDRLp.setEnabled(caso);
        jRadioVDRLn.setEnabled(caso);
        jRadioRHp.setEnabled(caso);
        jRadioRHn.setEnabled(caso);
        jRadioEspontaneo.setEnabled(caso);
        jRadioForceps.setEnabled(caso);
        jRadioCesarea.setEnabled(caso);
        jRadioInstitucional.setEnabled(caso);
        jRadioDomicilio.setEnabled(caso);
        jRadioPatEmbSi.setEnabled(caso);
        jRadioPatPartoSi.setEnabled(caso);
        jRadioPuerperioSi.setEnabled(caso);
        jRadioPatEmbNo.setEnabled(caso);
        jRadioPatPartoNo.setEnabled(caso);
        jRadioPuerperioNo.setEnabled(caso);
        jComboGrupo.setEnabled(caso);
    }
    
    public void controlGenero(){
        if (!niño.isSexo()){
            jLabelTitulo.setForeground(new java.awt.Color(255, 153, 0));
            jLabelTitular.setForeground(new java.awt.Color(255, 153, 0));
        }
    }
    
    public void deshabilitarCampos(){
        jTxtCualEmbarazo.setEnabled(false);
        jTxtCualParto.setEnabled(false);
        jTxtCualPuerperio.setEnabled(false);
        jTxtTratamiento.setEnabled(false);
    }
    
    public void habilitarCampos(){
        if(niño.getCarne().getEmbarazo().getTratamiento().equals("")
                && niño.getCarne().getEmbarazo().isVdrlMas()){
            jTxtTratamiento.setVisible(true);
            jTxtTratamiento.setEnabled(true);
        }
        if(niño.getCarne().getEmbarazo().getPatologiaEmbarazo().equals("")
                && niño.getCarne().getEmbarazo().isPatEmbarazoSi()){
            jTxtCualEmbarazo.setVisible(true);
            jTxtCualEmbarazo.setEnabled(true);
        }
        if(niño.getCarne().getEmbarazo().getPatologiaParto().equals("")
                && niño.getCarne().getEmbarazo().isPatPartoSi()){
            jTxtCualParto.setVisible(true);
            jTxtCualParto.setEnabled(true);
        }
        if(niño.getCarne().getEmbarazo().getPatologiaPuerperio().equals("")
                && niño.getCarne().getEmbarazo().isPatPuerperioSi()){
            jTxtCualPuerperio.setVisible(true);
            jTxtCualPuerperio.setEnabled(true);
        }
    }
    
    public void ocultarCampos(){
        if(niño.getCarne().getEmbarazo().isVdrlMenos()){
            jTxtTratamiento.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().isPatEmbarazoNo()){
            jTxtCualEmbarazo.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().isPatPartoNo()){
            jTxtCualParto.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().isPatPuerperioNo()){
            jTxtCualPuerperio.setVisible(false);
        }
    }
    
    public void cargarDatos(){
        jLabelNombre.setText(niño.toString());
        if(niño.getCarne().getEmbarazo().getNumero()!= 0){
            this.jLabelNumEmb.setText(Integer.toString(niño.getCarne().getEmbarazo().getNumero()));
            this.jTxtNumEmbarazo.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().getCantControles()!= -1){
            this.jLabelNumPre.setText(Integer.toString(niño.getCarne().getEmbarazo().getCantControles()));
            this.jTxtNumControles.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().isUnico()){
           this.jRadioEmbUnico.setSelected(true);
           this.jRadioEmbUnico.setEnabled(false);
           this.jRadioEmbMultiple.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isMultiple()){
           this.jRadioEmbMultiple.setSelected(true);
           this.jRadioEmbMultiple.setEnabled(false);
           this.jRadioEmbUnico.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isVdrlMas()){
           this.jRadioVDRLp.setSelected(true);
           this.jRadioVDRLp.setEnabled(false);
           this.jRadioVDRLn.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isVdrlMenos()){
           this.jRadioVDRLn.setSelected(true);
           this.jRadioVDRLp.setEnabled(false);
           this.jRadioVDRLn.setEnabled(false);
        }
        if(!niño.getCarne().getEmbarazo().getTratamiento().equals("")
                && !niño.getCarne().getEmbarazo().isVdrlMenos()){
            this.jLabelTrata.setText(niño.getCarne().getEmbarazo().getTratamiento());
            this.jTxtTratamiento.setVisible(false);
        }
        if(!niño.getCarne().getEmbarazo().getGrupoSanguineo().equals(" ")){
            this.jLabelCombo.setText(niño.getCarne().getEmbarazo().getGrupoSanguineo());
            this.jComboGrupo.setVisible(false);
        }
        if(niño.getCarne().getEmbarazo().isRhPos()){
           this.jRadioRHp.setSelected(true);
           this.jRadioRHp.setEnabled(false);
           this.jRadioRHn.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isRhNeg()){
           this.jRadioRHn.setSelected(true);
            this.jRadioRHp.setEnabled(false);
           this.jRadioRHn.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isEspontaneo()){
           this.jRadioEspontaneo.setSelected(true);
           this.jRadioEspontaneo.setEnabled(false);
           this.jRadioForceps.setEnabled(false);
           this.jRadioCesarea.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isForceps()){
           this.jRadioForceps.setSelected(true);
           this.jRadioEspontaneo.setEnabled(false);
           this.jRadioForceps.setEnabled(false);
           this.jRadioCesarea.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isCesarea()){
           this.jRadioCesarea.setSelected(true);
           this.jRadioEspontaneo.setEnabled(false);
           this.jRadioForceps.setEnabled(false);
           this.jRadioCesarea.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isInstitucional()){
           this.jRadioInstitucional.setSelected(true);
           this.jRadioInstitucional.setEnabled(false);
           this.jRadioDomicilio.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isEnDomicilio()){
           this.jRadioDomicilio.setSelected(true);
           this.jRadioInstitucional.setEnabled(false);
           this.jRadioDomicilio.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isPatEmbarazoSi()){
           this.jRadioPatEmbSi.setSelected(true);
           this.jRadioPatEmbSi.setEnabled(false);
           this.jRadioPatEmbNo.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isPatEmbarazoNo()){
           this.jRadioPatEmbNo.setSelected(true);
           this.jRadioPatEmbSi.setEnabled(false);
           this.jRadioPatEmbNo.setEnabled(false);
        
        }
        if(niño.getCarne().getEmbarazo().isPatPartoSi()){
           this.jRadioPatPartoSi.setSelected(true);
           this.jRadioPatPartoSi.setEnabled(false);
           this.jRadioPatPartoNo.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isPatPartoNo()){
           this.jRadioPatPartoNo.setSelected(true);
            this.jRadioPatPartoSi.setEnabled(false);
           this.jRadioPatPartoNo.setEnabled(false);
        }
        if(niño.getCarne().getEmbarazo().isPatPuerperioSi()){
           this.jRadioPuerperioSi.setSelected(true);
           this.jRadioPuerperioSi.setEnabled(false);
           this.jRadioPuerperioNo.setEnabled(false);
        }
        if( niño.getCarne().getEmbarazo().isPatPuerperioNo()){
           this.jRadioPuerperioNo.setSelected(true);
           this.jRadioPuerperioSi.setEnabled(false);
           this.jRadioPuerperioNo.setEnabled(false);
        }
        if(!niño.getCarne().getEmbarazo().getPatologiaEmbarazo().equals("")
                && !niño.getCarne().getEmbarazo().isPatEmbarazoNo()){
            this.jLabelCEmb.setText(niño.getCarne().getEmbarazo().getPatologiaEmbarazo());
            this.jTxtCualEmbarazo.setVisible(false);
        }
        if(!niño.getCarne().getEmbarazo().getPatologiaParto().equals("")
                && !niño.getCarne().getEmbarazo().isPatPartoNo()){
            this.jLabelCParto.setText(niño.getCarne().getEmbarazo().getPatologiaParto());
            this.jTxtCualParto.setVisible(false);
        }
        if(!niño.getCarne().getEmbarazo().getPatologiaPuerperio().equals("")
                && !niño.getCarne().getEmbarazo().isPatPuerperioNo()){
            this.jLabelCPuerp.setText(niño.getCarne().getEmbarazo().getPatologiaPuerperio());
            this.jTxtCualPuerperio.setVisible(false);
        }
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        buttonGroup4 = new javax.swing.ButtonGroup();
        buttonGroup5 = new javax.swing.ButtonGroup();
        buttonGroup6 = new javax.swing.ButtonGroup();
        buttonGroup7 = new javax.swing.ButtonGroup();
        buttonGroup8 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabelTitulo = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jTxtNumEmbarazo = new javax.swing.JTextField();
        jTxtNumControles = new javax.swing.JTextField();
        jTxtTratamiento = new javax.swing.JTextField();
        jTxtCualEmbarazo = new javax.swing.JTextField();
        jTxtCualParto = new javax.swing.JTextField();
        jTxtCualPuerperio = new javax.swing.JTextField();
        jBtnConfirmar = new javax.swing.JButton();
        jBtnSalir = new javax.swing.JButton();
        jRadioEmbUnico = new javax.swing.JRadioButton();
        jRadioEmbMultiple = new javax.swing.JRadioButton();
        jRadioVDRLp = new javax.swing.JRadioButton();
        jRadioVDRLn = new javax.swing.JRadioButton();
        jRadioRHp = new javax.swing.JRadioButton();
        jRadioRHn = new javax.swing.JRadioButton();
        jRadioEspontaneo = new javax.swing.JRadioButton();
        jRadioForceps = new javax.swing.JRadioButton();
        jRadioCesarea = new javax.swing.JRadioButton();
        jLabel24 = new javax.swing.JLabel();
        jRadioInstitucional = new javax.swing.JRadioButton();
        jRadioDomicilio = new javax.swing.JRadioButton();
        jRadioPatEmbSi = new javax.swing.JRadioButton();
        jRadioPatPartoSi = new javax.swing.JRadioButton();
        jRadioPuerperioSi = new javax.swing.JRadioButton();
        jRadioPatEmbNo = new javax.swing.JRadioButton();
        jRadioPatPartoNo = new javax.swing.JRadioButton();
        jRadioPuerperioNo = new javax.swing.JRadioButton();
        jComboGrupo = new javax.swing.JComboBox();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabelNumEmb = new javax.swing.JLabel();
        jLabelNumPre = new javax.swing.JLabel();
        jLabelTrata = new javax.swing.JLabel();
        jLabelCombo = new javax.swing.JLabel();
        jLabelCEmb = new javax.swing.JLabel();
        jLabelCParto = new javax.swing.JLabel();
        jLabelCPuerp = new javax.swing.JLabel();
        jLabelCambio = new javax.swing.JLabel();
        jLabelErrores = new javax.swing.JLabel();
        jLabelTitular = new javax.swing.JLabel();
        jLabelNombre = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Embarazo");
        setBounds(new java.awt.Rectangle(200, 100, 0, 0));
        setResizable(false);

        jPanel1.setLayout(null);

        jLabelTitulo.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabelTitulo.setForeground(new java.awt.Color(51, 153, 0));
        jLabelTitulo.setText("Embarazo");
        jPanel1.add(jLabelTitulo);
        jLabelTitulo.setBounds(20, 20, 170, 20);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(0, 50, 610, 10);

        jLabel2.setText("Número de embarazo");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 70, 150, 20);

        jLabel3.setText("Número de controles prenatales");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(280, 70, 200, 20);

        jLabel4.setText("Embarazo único");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(20, 100, 120, 20);

        jLabel5.setText("VDRL");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(20, 150, 40, 20);

        jLabel6.setText("Tratamiento");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(200, 150, 120, 20);

        jLabel7.setText("Grupo sanguíneo");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(20, 180, 120, 20);

        jLabel8.setText("RH");
        jPanel1.add(jLabel8);
        jLabel8.setBounds(280, 180, 30, 20);

        jLabel9.setText("Parto espontáneo");
        jPanel1.add(jLabel9);
        jLabel9.setBounds(20, 240, 110, 20);

        jLabel10.setText("Fórceps");
        jPanel1.add(jLabel10);
        jLabel10.setBounds(170, 240, 50, 20);

        jLabel11.setText("Cesárea");
        jPanel1.add(jLabel11);
        jLabel11.setBounds(270, 240, 50, 20);

        jLabel12.setText("Indtitucional");
        jPanel1.add(jLabel12);
        jLabel12.setBounds(20, 270, 80, 20);

        jLabel13.setText("Patología en el embarazo");
        jPanel1.add(jLabel13);
        jLabel13.setBounds(20, 310, 170, 20);

        jLabel14.setText("Patología en el parto");
        jPanel1.add(jLabel14);
        jLabel14.setBounds(20, 340, 120, 20);

        jLabel15.setText("Patología en el puerperio");
        jPanel1.add(jLabel15);
        jLabel15.setBounds(20, 370, 170, 20);

        jLabel16.setText("Cuál");
        jPanel1.add(jLabel16);
        jLabel16.setBounds(310, 310, 40, 20);

        jLabel17.setText("Cuál");
        jPanel1.add(jLabel17);
        jLabel17.setBounds(310, 340, 40, 20);

        jLabel18.setText("Cuál");
        jPanel1.add(jLabel18);
        jLabel18.setBounds(310, 370, 40, 20);

        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setText("+");
        jPanel1.add(jLabel19);
        jLabel19.setBounds(110, 150, 20, 20);

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel20.setText("-");
        jPanel1.add(jLabel20);
        jLabel20.setBounds(60, 150, 20, 20);

        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel21.setText("+");
        jPanel1.add(jLabel21);
        jLabel21.setBounds(350, 180, 20, 20);

        jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel22.setText("-");
        jPanel1.add(jLabel22);
        jLabel22.setBounds(310, 180, 20, 20);

        jLabel23.setText("Múltiple");
        jPanel1.add(jLabel23);
        jLabel23.setBounds(180, 100, 50, 20);

        jTxtNumEmbarazo.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTxtNumEmbarazo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jTxtNumEmbarazo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTxtNumEmbarazoFocusGained(evt);
            }
        });
        jPanel1.add(jTxtNumEmbarazo);
        jTxtNumEmbarazo.setBounds(170, 70, 20, 20);

        jTxtNumControles.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTxtNumControles.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jTxtNumControles.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTxtNumControlesFocusGained(evt);
            }
        });
        jPanel1.add(jTxtNumControles);
        jTxtNumControles.setBounds(480, 70, 20, 20);

        jTxtTratamiento.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jPanel1.add(jTxtTratamiento);
        jTxtTratamiento.setBounds(280, 150, 310, 20);

        jTxtCualEmbarazo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jPanel1.add(jTxtCualEmbarazo);
        jTxtCualEmbarazo.setBounds(350, 310, 240, 20);

        jTxtCualParto.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jPanel1.add(jTxtCualParto);
        jTxtCualParto.setBounds(350, 340, 240, 20);

        jTxtCualPuerperio.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jPanel1.add(jTxtCualPuerperio);
        jTxtCualPuerperio.setBounds(350, 370, 240, 20);

        jBtnConfirmar.setText("Confirmar Cambios");
        jBtnConfirmar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jBtnConfirmarMouseExited(evt);
            }
        });
        jBtnConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnConfirmarActionPerformed(evt);
            }
        });
        jPanel1.add(jBtnConfirmar);
        jBtnConfirmar.setBounds(130, 460, 130, 23);

        jBtnSalir.setText("Salir");
        jBtnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnSalirActionPerformed(evt);
            }
        });
        jPanel1.add(jBtnSalir);
        jBtnSalir.setBounds(360, 460, 130, 23);

        jRadioEmbUnico.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup1.add(jRadioEmbUnico);
        jPanel1.add(jRadioEmbUnico);
        jRadioEmbUnico.setBounds(140, 100, 20, 21);

        jRadioEmbMultiple.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup1.add(jRadioEmbMultiple);
        jPanel1.add(jRadioEmbMultiple);
        jRadioEmbMultiple.setBounds(230, 100, 20, 21);

        jRadioVDRLp.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup2.add(jRadioVDRLp);
        jRadioVDRLp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioVDRLpActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioVDRLp);
        jRadioVDRLp.setBounds(130, 150, 20, 20);

        jRadioVDRLn.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup2.add(jRadioVDRLn);
        jRadioVDRLn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioVDRLnActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioVDRLn);
        jRadioVDRLn.setBounds(80, 150, 20, 20);

        jRadioRHp.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup3.add(jRadioRHp);
        jPanel1.add(jRadioRHp);
        jRadioRHp.setBounds(370, 180, 20, 20);

        jRadioRHn.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup3.add(jRadioRHn);
        jPanel1.add(jRadioRHn);
        jRadioRHn.setBounds(330, 180, 20, 20);

        jRadioEspontaneo.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup4.add(jRadioEspontaneo);
        jPanel1.add(jRadioEspontaneo);
        jRadioEspontaneo.setBounds(130, 240, 20, 20);

        jRadioForceps.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup4.add(jRadioForceps);
        jPanel1.add(jRadioForceps);
        jRadioForceps.setBounds(220, 240, 20, 20);

        jRadioCesarea.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup4.add(jRadioCesarea);
        jPanel1.add(jRadioCesarea);
        jRadioCesarea.setBounds(320, 240, 20, 20);

        jLabel24.setText("En Domicilio/otro");
        jPanel1.add(jLabel24);
        jLabel24.setBounds(180, 270, 100, 20);

        jRadioInstitucional.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup5.add(jRadioInstitucional);
        jPanel1.add(jRadioInstitucional);
        jRadioInstitucional.setBounds(110, 270, 20, 20);

        jRadioDomicilio.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup5.add(jRadioDomicilio);
        jPanel1.add(jRadioDomicilio);
        jRadioDomicilio.setBounds(280, 270, 20, 20);

        jRadioPatEmbSi.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup6.add(jRadioPatEmbSi);
        jRadioPatEmbSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPatEmbSiActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPatEmbSi);
        jRadioPatEmbSi.setBounds(280, 310, 20, 20);

        jRadioPatPartoSi.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup7.add(jRadioPatPartoSi);
        jRadioPatPartoSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPatPartoSiActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPatPartoSi);
        jRadioPatPartoSi.setBounds(280, 340, 20, 20);

        jRadioPuerperioSi.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup8.add(jRadioPuerperioSi);
        jRadioPuerperioSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPuerperioSiActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPuerperioSi);
        jRadioPuerperioSi.setBounds(280, 370, 20, 20);

        jRadioPatEmbNo.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup6.add(jRadioPatEmbNo);
        jRadioPatEmbNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPatEmbNoActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPatEmbNo);
        jRadioPatEmbNo.setBounds(220, 310, 20, 20);

        jRadioPatPartoNo.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup7.add(jRadioPatPartoNo);
        jRadioPatPartoNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPatPartoNoActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPatPartoNo);
        jRadioPatPartoNo.setBounds(220, 340, 20, 20);

        jRadioPuerperioNo.setBackground(new java.awt.Color(255, 255, 0));
        buttonGroup8.add(jRadioPuerperioNo);
        jRadioPuerperioNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioPuerperioNoActionPerformed(evt);
            }
        });
        jPanel1.add(jRadioPuerperioNo);
        jRadioPuerperioNo.setBounds(220, 370, 20, 20);

        jComboGrupo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "O", "A", "B", "AB" }));
        jComboGrupo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, null, new java.awt.Color(255, 255, 0), null, new java.awt.Color(204, 204, 0)));
        jPanel1.add(jComboGrupo);
        jComboGrupo.setBounds(140, 180, 70, 20);

        jLabel25.setText("Si");
        jPanel1.add(jLabel25);
        jLabel25.setBounds(260, 310, 15, 20);

        jLabel26.setText("Si");
        jPanel1.add(jLabel26);
        jLabel26.setBounds(260, 340, 15, 20);

        jLabel27.setText("Si");
        jPanel1.add(jLabel27);
        jLabel27.setBounds(260, 370, 15, 20);

        jLabel28.setText("No");
        jPanel1.add(jLabel28);
        jLabel28.setBounds(200, 310, 15, 20);

        jLabel29.setText("No");
        jPanel1.add(jLabel29);
        jLabel29.setBounds(200, 340, 15, 20);

        jLabel30.setText("No");
        jPanel1.add(jLabel30);
        jLabel30.setBounds(200, 370, 15, 20);

        jLabelNumEmb.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelNumEmb.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelNumEmb);
        jLabelNumEmb.setBounds(170, 70, 20, 20);

        jLabelNumPre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelNumPre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelNumPre);
        jLabelNumPre.setBounds(480, 70, 20, 20);

        jLabelTrata.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelTrata);
        jLabelTrata.setBounds(280, 150, 310, 20);

        jLabelCombo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelCombo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelCombo);
        jLabelCombo.setBounds(140, 180, 70, 20);

        jLabelCEmb.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelCEmb);
        jLabelCEmb.setBounds(350, 310, 240, 20);

        jLabelCParto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelCParto);
        jLabelCParto.setBounds(350, 340, 240, 20);

        jLabelCPuerp.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.add(jLabelCPuerp);
        jLabelCPuerp.setBounds(350, 370, 240, 20);

        jLabelCambio.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelCambio.setText("El cambio se ha realizado");
        jPanel1.add(jLabelCambio);
        jLabelCambio.setBounds(140, 430, 150, 14);

        jLabelErrores.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelErrores.setForeground(new java.awt.Color(255, 0, 0));
        jLabelErrores.setText("No se han guardado los datos marcados en rojo");
        jPanel1.add(jLabelErrores);
        jLabelErrores.setBounds(90, 430, 300, 14);

        jLabelTitular.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabelTitular.setForeground(new java.awt.Color(51, 153, 0));
        jLabelTitular.setText("Titular:");
        jPanel1.add(jLabelTitular);
        jLabelTitular.setBounds(330, 25, 50, 20);

        jLabelNombre.setFont(new java.awt.Font("Tahoma", 1, 14));
        jPanel1.add(jLabelNombre);
        jLabelNombre.setBounds(390, 25, 220, 20);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jRadioPatEmbNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPatEmbNoActionPerformed
    this.jTxtCualEmbarazo.setEnabled(false);
    this.jTxtCualEmbarazo.setText("");
}//GEN-LAST:event_jRadioPatEmbNoActionPerformed

private void jRadioPatPartoNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPatPartoNoActionPerformed
    this.jTxtCualParto.setEnabled(false);
    this.jTxtCualParto.setText("");
}//GEN-LAST:event_jRadioPatPartoNoActionPerformed

private void jRadioPuerperioNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPuerperioNoActionPerformed
    this.jTxtCualPuerperio.setEnabled(false);
    this.jTxtCualPuerperio.setText("");
}//GEN-LAST:event_jRadioPuerperioNoActionPerformed

private void jRadioPatEmbSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPatEmbSiActionPerformed
    this.jTxtCualEmbarazo.setEnabled(true);
}//GEN-LAST:event_jRadioPatEmbSiActionPerformed

private void jRadioPatPartoSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPatPartoSiActionPerformed
    this.jTxtCualParto.setEnabled(true);
}//GEN-LAST:event_jRadioPatPartoSiActionPerformed

private void jRadioPuerperioSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioPuerperioSiActionPerformed
     this.jTxtCualPuerperio.setEnabled(true);
}//GEN-LAST:event_jRadioPuerperioSiActionPerformed

private void jBtnConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnConfirmarActionPerformed
    if(jTxtNumEmbarazo.isEnabled() && !jTxtNumEmbarazo.getText().equals("")){ 
       if(modelo.controlEnteroPos(jTxtNumEmbarazo.getText())
               && niño.getCarne().getEmbarazo().controlCantEmbarazo(Integer.parseInt(jTxtNumEmbarazo.getText()))){
            niño.getCarne().getEmbarazo().setNumero(Integer.parseInt(jTxtNumEmbarazo.getText()));
       }else{
           this.jTxtNumEmbarazo.setBackground(Color.red);
       }
    }
    if(jTxtNumControles.isEnabled() && !jTxtNumControles.getText().equals("")){ 
       if(modelo.controlEnteroCero(jTxtNumControles.getText())
               && niño.getCarne().getEmbarazo().controlCantControles(Integer.parseInt(jTxtNumControles.getText()))){
            niño.getCarne().getEmbarazo().setCantControles(Integer.parseInt(jTxtNumControles.getText()));
       }else{
           this.jTxtNumControles.setBackground(Color.red);
       }
    }
    if(jRadioEmbUnico.isEnabled()){
        niño.getCarne().getEmbarazo().setUnico(jRadioEmbUnico.isSelected());
    }
    if(jRadioEmbMultiple.isEnabled()){
        niño.getCarne().getEmbarazo().setMultiple(jRadioEmbMultiple.isSelected());
    }
    if(jRadioVDRLn.isEnabled()){
        niño.getCarne().getEmbarazo().setVdrlMenos(jRadioVDRLn.isSelected());
    }
    if(jRadioVDRLp.isEnabled()){
        niño.getCarne().getEmbarazo().setVdrlMas(jRadioVDRLp.isSelected());
    }
    if(!jTxtTratamiento.getText().equals("") && jRadioVDRLp.isSelected()){
        niño.getCarne().getEmbarazo().setTratamiento(jTxtTratamiento.getText());
    }
    if(jComboGrupo.isEnabled()){
        niño.getCarne().getEmbarazo().setGrupoSanguineo(jComboGrupo.getSelectedItem().toString());
    }
    if(jRadioRHn.isEnabled()){
        niño.getCarne().getEmbarazo().setRhNeg(jRadioRHn.isSelected());
    }
    if(jRadioRHp.isEnabled()){
        niño.getCarne().getEmbarazo().setRhPos(jRadioRHp.isSelected());
    }
    if(jRadioEspontaneo.isEnabled()){
        niño.getCarne().getEmbarazo().setEspontaneo(jRadioEspontaneo.isSelected());
    }
    if(jRadioForceps.isEnabled()){
        niño.getCarne().getEmbarazo().setForceps(jRadioForceps.isSelected());
    }
    if(jRadioCesarea.isEnabled()){
        niño.getCarne().getEmbarazo().setCesarea(jRadioCesarea.isSelected());
    }
    if(jRadioInstitucional.isEnabled()){
        niño.getCarne().getEmbarazo().setInstitucional(jRadioInstitucional.isSelected());
    }
    if(jRadioDomicilio.isEnabled()){
        niño.getCarne().getEmbarazo().setEnDomicilio(jRadioDomicilio.isSelected());
    }
    if(jRadioPatEmbNo.isEnabled()){
        niño.getCarne().getEmbarazo().setPatEmbarazoNo(jRadioPatEmbNo.isSelected());
    }
    if(jRadioPatEmbSi.isEnabled()){
        niño.getCarne().getEmbarazo().setPatEmbarazoSi(jRadioPatEmbSi.isSelected());
    }
    if(jRadioPatPartoNo.isEnabled()){
        niño.getCarne().getEmbarazo().setPatPartoNo(jRadioPatPartoNo.isSelected());
    }
    if(jRadioPatPartoSi.isEnabled()){
        niño.getCarne().getEmbarazo().setPatPartoSi(jRadioPatPartoSi.isSelected());
    }
    if(jRadioPuerperioNo.isEnabled()){
        niño.getCarne().getEmbarazo().setPatPuerperioNo(jRadioPuerperioNo.isSelected());
    }
    if(jRadioPuerperioSi.isEnabled()){
        niño.getCarne().getEmbarazo().setPatPuerperioSi(jRadioPuerperioSi.isSelected());
    }
    if(!jTxtCualEmbarazo.getText().equals("") && jRadioPatEmbSi.isSelected()){
        niño.getCarne().getEmbarazo().setPatologiaEmbarazo(jTxtCualEmbarazo.getText());
    }
    if(!jTxtCualParto.getText().equals("") && jRadioPatPartoSi.isSelected()){
        niño.getCarne().getEmbarazo().setPatologiaParto(jTxtCualParto.getText());
    }
    if(!jTxtCualPuerperio.getText().equals("") && jRadioPuerperioSi.isSelected()){
        niño.getCarne().getEmbarazo().setPatologiaPuerperio(jTxtCualPuerperio.getText());
    }
    if(jTxtNumEmbarazo.getBackground().equals(Color.red) || jTxtNumControles.getBackground().equals(Color.red)){
        jLabelErrores.setVisible(true);
    } else{
        jLabelCambio.setVisible(true);
    }
    
}//GEN-LAST:event_jBtnConfirmarActionPerformed

private void jBtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jBtnSalirActionPerformed

private void jRadioVDRLnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioVDRLnActionPerformed
    this.jTxtTratamiento.setEnabled(false);
    this.jTxtTratamiento.setText("");
}//GEN-LAST:event_jRadioVDRLnActionPerformed

private void jRadioVDRLpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioVDRLpActionPerformed
    this.jTxtTratamiento.setEnabled(true);
}//GEN-LAST:event_jRadioVDRLpActionPerformed

    private void jBtnConfirmarMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtnConfirmarMouseExited
        this.jLabelCambio.setVisible(false);
    }//GEN-LAST:event_jBtnConfirmarMouseExited

    private void jTxtNumEmbarazoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTxtNumEmbarazoFocusGained
        this.jTxtNumEmbarazo.setBackground(Color.white);
        this.jLabelErrores.setVisible(false);
    }//GEN-LAST:event_jTxtNumEmbarazoFocusGained

    private void jTxtNumControlesFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTxtNumControlesFocusGained
        this.jTxtNumControles.setBackground(Color.white);
        this.jLabelErrores.setVisible(false);
    }//GEN-LAST:event_jTxtNumControlesFocusGained

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.ButtonGroup buttonGroup4;
    private javax.swing.ButtonGroup buttonGroup5;
    private javax.swing.ButtonGroup buttonGroup6;
    private javax.swing.ButtonGroup buttonGroup7;
    private javax.swing.ButtonGroup buttonGroup8;
    private javax.swing.JButton jBtnConfirmar;
    private javax.swing.JButton jBtnSalir;
    private javax.swing.JComboBox jComboGrupo;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCEmb;
    private javax.swing.JLabel jLabelCParto;
    private javax.swing.JLabel jLabelCPuerp;
    private javax.swing.JLabel jLabelCambio;
    private javax.swing.JLabel jLabelCombo;
    private javax.swing.JLabel jLabelErrores;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelNumEmb;
    private javax.swing.JLabel jLabelNumPre;
    private javax.swing.JLabel jLabelTitular;
    private javax.swing.JLabel jLabelTitulo;
    private javax.swing.JLabel jLabelTrata;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioCesarea;
    private javax.swing.JRadioButton jRadioDomicilio;
    private javax.swing.JRadioButton jRadioEmbMultiple;
    private javax.swing.JRadioButton jRadioEmbUnico;
    private javax.swing.JRadioButton jRadioEspontaneo;
    private javax.swing.JRadioButton jRadioForceps;
    private javax.swing.JRadioButton jRadioInstitucional;
    private javax.swing.JRadioButton jRadioPatEmbNo;
    private javax.swing.JRadioButton jRadioPatEmbSi;
    private javax.swing.JRadioButton jRadioPatPartoNo;
    private javax.swing.JRadioButton jRadioPatPartoSi;
    private javax.swing.JRadioButton jRadioPuerperioNo;
    private javax.swing.JRadioButton jRadioPuerperioSi;
    private javax.swing.JRadioButton jRadioRHn;
    private javax.swing.JRadioButton jRadioRHp;
    private javax.swing.JRadioButton jRadioVDRLn;
    private javax.swing.JRadioButton jRadioVDRLp;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTxtCualEmbarazo;
    private javax.swing.JTextField jTxtCualParto;
    private javax.swing.JTextField jTxtCualPuerperio;
    private javax.swing.JTextField jTxtNumControles;
    private javax.swing.JTextField jTxtNumEmbarazo;
    private javax.swing.JTextField jTxtTratamiento;
    // End of variables declaration//GEN-END:variables
}
